package com.view.resourcemanage.CustomerFrame;

import com.bean.Customer;
import com.lovo.netCRM.component.LovoButton;
import com.service.CustomerService;
import com.service.impl.CustomerServiceImpl;
import com.view.MainFrame;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class CustomerShowDialog extends JDialog{

    private LovoButton addBtn;
    private LovoButton cancelBtn;
    private JLabel nameTxt,directorTxt,telTxt,emailTxt,addressTxt,rangeTxt;


    private MainFrame frame ;
    private int key;
    private CustomerService customerService = new CustomerServiceImpl();

    public CustomerShowDialog(MainFrame frame,int key) {
        // TODO Auto-generated constructor stub
        super(frame,"添加新客户",true);
        this.frame = frame;
        this.key = key;
        this.setBounds(350, 250, 520, 400);
        this.setLayout(null);
        this.init();
        this.setVisible(true);

    }



    private void init() {
        // TODO Auto-generated method stub
        Customer customer = new Customer();
        customer = customerService.getCustomerInfo(key);

        System.out.println(customer.getName());

        nameTxt = new JLabel();
        nameTxt.setBounds(20,20,150,60);
        nameTxt.setText("<html>客户："+customer.getName()+" </html>");
        this.add(nameTxt);

        directorTxt = new JLabel();
        directorTxt.setBounds(20,90,150,60);
        directorTxt.setText("<html>负责人："+customer.getDirector()+" </html>");
        this.add(directorTxt);

        telTxt = new JLabel();
        telTxt.setBounds(20,160,150,60);
        telTxt.setText("<html>联系方式："+customer.getDirectorTel()+" </html>");
        this.add(telTxt);

        emailTxt = new JLabel();
        emailTxt.setBounds(300,20,150,60);
        emailTxt.setText("<html>邮箱："+customer.getDirectorEmail()+" </html>");
        this.add(emailTxt);


        addressTxt = new JLabel();
        addressTxt.setBounds(300,90,150,60);
        addressTxt.setText("<html>地址："+customer.getAddress()+" </html>");
        this.add(addressTxt);

        rangeTxt = new JLabel();
        rangeTxt.setBounds(300,160,150,60);
        rangeTxt.setText("<html>经营范围："+customer.getManageRange()+" </html>");
        this.add(rangeTxt);


        this.cancelBtn = new LovoButton("取消", 270, 320, this);

        cancelBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                CustomerShowDialog.this.dispose();;
            }
        });

    }


}
